# -*- coding: UTF-8 -*-
"""
@Project ：lufei-learning-city 
@File    ：锁的实际应用.py
@IDE     ：PyCharm 
@Author  ：于金龙@阿龙的代码在报错
@Date    ：2024/9/28 下午4:24 
"""
import pymysql


def task():
    conn = pymysql.connect(host='localhost',
                           port=3306,
                           user='root',
                           password='20020115',
                           charset='utf8',
                           db='day29')
    cursor = conn.cursor(pymysql.cursors.DictCursor)
    # 开启事务
    conn.begin()
    cursor.execute('select * from day29.tb where id = 1  for update ')
    result = cursor.fetchall()
    num = result[0]['num']
    if num > 0:
        cursor.execute("update ")


if __name__ == '__main__':
    task()
